home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-27 | 5.4 KB | 250 lines | [TEXT/MPS ] |
- Set Echo 0
-
- #
- #
- # File: sc or somc (sc operates case sensitive)
- # Function: Drive the som compiler program like sc for SOM
- #
- #
-
-
- If {#} == 0
- Begin
- Echo "# Usage: {0} " '∂'
- Echo "# [ -D define ] [ -e emitter1,emitter2 ] [ -I folder ] [ -keeptm ] " '∂'
- Echo "# [ -m modifier ] [ -o outfolder ] [ -other" '"option"' "] " '∂'
- Echo "# [ -p ] [ -r ] [ -v ] [ -w ] [ -x ] " '∂'
- Echo "# file(s).idl"
- End > Dev:StdErr
- Exit 1
- End
-
- If "{0}" =~ /(≈:)«0,1»sc/
- Set CaseSensitive 1 # emulate unix - case counts
- Else
- Set CaseSensitive 0 # allow either case
- End
-
-
- Unset MyIncludes
- Unset MyDefines
- Unset MyFiles
- Unset MyEmitters
- Unset MyOptions
- Unset OutDir
- Unset EmitCtm
- Unset EmitXtm
- Unset Verbose
- Unset PPOnly
- Unset KeepTM
-
- Loop
- Break If {#} == 0
-
- # Echo "{1}"
-
- If "{1}" =~ /-p/
- Set MyDefines "{MyDefines} -D __PRIVATE__"
- Else If "{1}" =~ /-v/
- Set Verbose 1
- Set MyOptions "{MyOptions} -v"
- Else If "{1}" =~ /-x/
- Set PPOnly 1
- Else If "{1}" =~ /-r/
- Set MyOptions "{MyOptions} -r"
- Else If "{1}" =~ /-w/
- Set MyOptions "{MyOptions} -w"
- Else If "{1}" =~ /-keeptm/
- Set KeepTM 1
- Else If "{1}" =~ /-D(≈)®1/
- # Preprocessor define specification
- If "{®1}" == ""
- Shift
- Else
- Set 1 "{®1}"
- End
- Set MyDefines "{MyDefines} -D '{1}'"
- Else If "{1}" =~ /-I(≈)®1/
- # Include folder specification
- If "{®1}" == ""
- Shift
- Else
- Set 1 "{®1}"
- End
- Set MyIncludes "{MyIncludes} -I '{1}'"
- Else If "{1}" =~ /-m(≈)®1/
- # Modifier options
- If "{®1}" == ""
- Shift
- Else
- Set 1 "{®1}"
- End
- Set MyOptions "{MyOptions} -m'{1}'"
- Else If "{1}" =~ /-other(≈)®1/
- # Modifier options
- If "{®1}" == ""
- Shift
- Else
- Set 1 "{®1}"
- End
- Set MyOptions "{MyOptions} {1}"
- Else If "{1}" =~ /-[od](≈)®1/ # -o for scom, -d for sc
- # Output folder specification
- If "{OutDir}" != ""
- Echo "### {0} - OutFolder option already specified" > Dev:StdErr
- Exit 1
- End
- If "{®1}" == ""
- Shift
- Else
- Set 1 "{®1}"
- End
- Set OutDir "{1}" # quoted whenever used
- Else If "{1}" =~ /-[se](≈)®1/
- # Emitter specification parameter
- If "{®1}" == ""
- Shift
- Else
- Set 1 "{®1}"
- End
- Loop
- Break If "{1}" !~ /([¬;,]*)®1≈/
- If {EmitCtm} == 0
- If "{®1}" =~ /c/
- # insert the ctm emitter if calling the c emitter
- Set MyEmitters "{MyEmitters} -e emitctm.dll"
- Set EmitCtm 1
- End
- End
- If {EmitXtm} == 0
- If "{®1}" =~ /xc/
- # insert the xtm emitter if calling the xc emitter
- Set MyEmitters "{MyEmitters} -e emitxtm.dll"
- Set EmitXtm 1
- End
- End
- Set MyEmitters "{MyEmitters} -e emit'{®1}'.dll"
- Break If "{1}" !~ /[¬;,]*[;,](≈)®1/
- Set 1 "{®1}"
- End
- Else If "{1}" !~ /-≈/
- # Source file parameter
- Set MyFiles "{MyFiles} '{1}'"
- Else
- Begin
- Echo "### {0} - Option {1} unknown."
- Echo "# Use -other" '"-xyz"' "to pass unknown options through."
- Echo "# For example, {0} -other" '"-S ddd"' " ..."
- End > Dev:StdErr
- Exit 1
- End
-
- Shift
- End # for each input parameter
-
-
- If "{MyFiles}" == ""
- Echo "### {0} - no source files supplied" > Dev:StdErr
- Exit 1
- End
-
- If "{MyEmitters}" == ""
- Echo "### {0} - no emitters specified" > Dev:StdErr
- Exit 1
- End
-
-
- # insure that OutDir ends with a : because it is concatenated to a filename
- If "{OutDir}" != ""
- If "{OutDir}" !~ /≈:/
- Set OutDir "{OutDir}:"
- End
- End
-
-
- Set Temp "{TempFolder}sc.temp.idl.e"
-
-
- Unset CIncludes # because we use C to preprocess idl files.
- Unset theFile theEmitter Output OldExit
- Unset IPCStatus __somIncludes __somExpandedIncs
-
- # expand SOMIncludes
- if "{SOMIncludes}" != ""
- set __somIncludes "{SOMIncludes}"
- loop
- break if "{__somIncludes}" !~ /(≈)®1,(≈)®2/
- set __somIncludes "{®1}"
- set __somExpandedIncs "-I `quote "{®2}"` {__somExpandedIncs}"
- end
- set MyIncludes "{MyIncludes} -I `quote "{__somIncludes}"` {__somExpandedIncs}"
- end
-
- For theFile in {MyFiles}
-
- If {Verbose}
- Quote CParser -pp -a -ext off -nocomments "{theFile}" {MyDefines} {SOMDefines} {MyIncludes} -ppout "{Temp}"
- End
- CParser -pp -a -ext off -nocomments "{theFile}" {MyDefines} {SOMDefines} {MyIncludes} -ppout "{Temp}"
-
- # If OutDir is empty then we send result files to the current folder,
- # no matter what dir the source file came from.
-
- If "{theFile}" =~ /(≈:)«0,1»(≈)®1.(≈)/ ## /(≈):(≈)®1.(≈)/ || /(≈)®1.(≈)/
- Set Output "{OutDir}{®1}"
- Else If "{theFile}" =~ /(≈):(≈)®1/
- Set Output "{OutDir}{®1}"
- Else
- Set Output "{OutDir}{theFile}"
- End
-
- # Ensure that the compiler generates bindings for the Macintosh
- Set MyOptions "{MyOptions} -mmom"
-
- If {Verbose}
- Quote somipc {MyOptions} {MyEmitters} {SOMOptions} -o "{Output}" "{Temp}"
- End
- If {PPOnly}
- Echo "### SOM compiler not invoked (option -x set)."
- Exit "-1"
- End
-
- Delete -y -i stderr # powerpc IT & FT
- Set OldExit {Exit}
- Set Exit 0
- somipc {MyOptions} {MyEmitters} {SOMOptions} -o "{Output}" "{Temp}"
- Set IPCStatus {Status}
- Set Exit {OldExit}
-
- If "`Exists stderr`"
- Catenate stderr # powerpc IT & FT
- Delete -y -i stderr # powerpc IT & FT
- End
- If {IPCStatus}
- Echo "### Exiting due to errors in SOM compile phase."
- Exit "{IPCStatus}"
- End
-
- If {KeepTM}
- Else
- If {EmitCtm}
- If {Verbose}
- Quote Delete -y -i "{Output}.ctm"
- End
- Delete -y -i "{Output}.ctm"
- End
- If {EmitXtm}
- If {Verbose}
- Quote Delete -y -i "{Output}.xtm"
- End
- Delete -y -i "{Output}.xtm"
- End
- End
- End # for each idl file
-
-
- If {Verbose}
- Quote Delete -y -i "{Temp}"
- End
- Delete -y -i "{Temp}"
-